<?php

namespace frontend\helpers;

class SitemapHelper
{
    public static function rebuildPagePath($pageCollection)
    {
        foreach($pageCollection as &$page)
        {
            $page['path'] = explode('/', $page['path']);
            $newPath = array();
            for ($j=1; $j < count($page['path']); $j++) 
            { 
                $newPath[] = $pageCollection[$page['path'][$j]]['alias'];
            }
            $page['path'] = implode('/', $newPath);
        }

        foreach($pageCollection as $key => &$page)
        {
            if($page['is_draft'] || $page['is_hidden'])
            {
                unset($pageCollection[$key]);
            }
        }
        return $pageCollection;
    }
}